﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/Foothill.Master" AutoEventWireup="true" 
    CodeBehind="ForSaleList.aspx.cs" Inherits="Foothill.Web.ForSaleList" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="stylesheet" href="ad-list.css" type="text/css" /> 
    <link rel="stylesheet" href="pagination.css" type="text/css" />
    <link rel="stylesheet" href="../bootstrap-select/bootstrap-select.css" type="text/css" />
    <script type="text/javascript" src="../bootstrap-select/bootstrap-select.min.js"></script>
    <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>

    <script type="text/javascript">
        $(function () {
            $(".selectpicker").selectpicker();
        });

        function pageLoad(sender, args) {
            $(".selectpicker").selectpicker();

            $(".hlkSavePost").click(function () {
                var url = $(this).attr("href");
                var saveLinkId = $(this).attr("id");
                var tokens = url.split('#');

                $.ajax({
                    type: "POST",
                    url: "ForSaleList.aspx/SavePost",
                    data: '{"userId": "' + tokens[0] + '", "postId": "' + tokens[1] + '"}',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) {
                        $('#'.concat(tokens[2])).show('slow');
                        $('#'.concat(saveLinkId)).hide();
                    }
                });

                return false;
            });
        }
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cph1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <div id="for-sale-list"> 
        <asp:UpdatePanel ID="udpQuickFind" runat="server">
            <Triggers>
                <asp:PostBackTrigger ControlID="btnQuickSearch" />
            </Triggers>
            <ContentTemplate>
                <table class="quick-find-tbl">
                    <tr>
                        <td class="td-ddlMake">
                            <asp:DropDownList ID="ddlMake" runat="server" CssClass="quick-search-ddl selectpicker" OnSelectedIndexChanged="ddlMake_OnSelectedIndexChanged" />
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlModel" runat="server" CssClass="quick-search-ddlModel selectpicker" />
                        </td>
                        </td>
                        <td>
                            <asp:Label ID="lblMilage" runat="server" Text="里程" CssClass="quick-search-label" />
                            <asp:DropDownList ID="ddlMileage" runat="server" CssClass="quick-search-shortddl selectpicker" />
                        </td>
                        <td class="qk-find-shortddl">
                            <asp:Label ID="lblCity" runat="server" Text="价格" CssClass="quick-search-label" />
                            <asp:DropDownList ID="ddlPrice" runat="server" CssClass="quick-search-ddlPrice selectpicker" />
                            <span>to</span>
                            <asp:DropDownList ID="ddlPriceTo" runat="server" CssClass="quick-search-ddlPrice selectpicker" />
                        </td>
                        <td class="qk-find-btn">
                            <div class="qk-search-btn">
                                <asp:LinkButton ID="btnQuickSearch" runat="server" Text="搜索" OnClick="btnQuickSearch_Click"
                                    CssClass="btnQuickSearch btn btn-warning" />   
                            </div>
                        </td>
                    </tr>
                </table>  
                <div class="adv-search-btn">
                    <a href="../ForSaleAdvancedSearch/ForSaleAdvancedSearch.aspx" target="_blank">高级搜索 ></a>
                </div>
                <div class="clear"></div>
            </ContentTemplate>
        </asp:UpdatePanel>
        <div id="hr-sale-list"></div>
        <asp:UpdatePanel ID="udpFilters" runat="server">
            <ContentTemplate>   
                <div id="sale-list-search">
                    <div class="list-search-firstth list-search-th">
                        公里数:
                    </div>
            
                    <div class="list-search-block"> 
                        <asp:GridView ID="gvwGroupByMileage" runat="server" AutoGenerateColumns="false" AllowPaging="false" DataKeyNames="GroupId"
                             AllowSorting="false" CssClass="gvwFilterItem" OnRowDataBound="gvwGroupByStatsOnRowDataBound" ShowHeader="false">
                            <Columns>
                                <asp:TemplateField ShowHeader="false" >
                                    <ItemTemplate> 
                                        <div class="search-list-group">
                                            <asp:CheckBox ID="cbxGroupName" runat="server" AutoPostBack="true" OnCheckedChanged="MileageCheckBoxCheckedChanged" CssClass="cbxGroupName"  />
                                            <asp:Label ID="lblCount" runat="server" CssClass="lblCount" />
                                        </div>     
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </div>

                    <div class="list-search-th">
                        车龄:
                    </div>
            
                    <div class="list-search-block"> 
                        <asp:GridView ID="gvwGroupByYearAge" runat="server" AutoGenerateColumns="false" AllowPaging="false" DataKeyNames="GroupId"
                             AllowSorting="false" CssClass="gvwFilterItem" OnRowDataBound="gvwGroupByStatsOnRowDataBound" ShowHeader="false">
                            <Columns>
                                <asp:TemplateField ShowHeader="false" >
                                    <ItemTemplate> 
                                        <div class="search-list-group">
                                            <asp:CheckBox ID="cbxGroupName" runat="server" AutoPostBack="true" OnCheckedChanged="YearAgeCheckBoxCheckedChanged" CssClass="cbxGroupName" />
                                            <asp:Label ID="lblCount" runat="server" CssClass="lblCount" />
                                        </div>     
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </div>

                    <div class="list-search-th">
                        品牌:
                    </div>

                    <div class="list-search-block">
                        <asp:GridView ID="gvwGroupByMakes" runat="server" AutoGenerateColumns="false" AllowPaging="false" DataKeyNames="GroupId"
                             AllowSorting="false" CssClass="gvwFilterItem" OnRowDataBound="gvwGroupByStatsOnRowDataBound" ShowHeader="false">
                            <Columns>
                                <asp:TemplateField ShowHeader="false" >
                                    <ItemTemplate> 
                                        <div class="search-list-group">
                                            <asp:CheckBox ID="cbxGroupName" runat="server" AutoPostBack="true" OnCheckedChanged="cbxMake_CheckedChanged" CssClass="cbxGroupName" />
                                            <asp:Label ID="lblCount" runat="server" CssClass="lblCount"/>
                                        </div>     
                                    </ItemTemplate>
                                </asp:TemplateField>    
                            </Columns>
                        </asp:GridView>   
                    </div>
            
                    <div class="list-search-th">
                        城市:
                    </div>
            
                    <div class="list-search-block">
                        <asp:GridView ID="gvwGroupByCity" runat="server" AutoGenerateColumns="false" AllowPaging="false" DataKeyNames="GroupId"
                             AllowSorting="false" CssClass="gvwFilterItem" OnRowDataBound="gvwGroupByStatsOnRowDataBound" ShowHeader="false">
                            <Columns>
                                <asp:TemplateField ShowHeader="false">
                                    <ItemTemplate> 
                                        <div class="search-list-group">
                                            <asp:CheckBox ID="cbxGroupName" runat="server" AutoPostBack="true" OnCheckedChanged="cbxCity_CheckedChanged" CssClass="cbxGroupName" />
                                            <asp:Label ID="lblCount" runat="server" CssClass="lblCount" />
                                        </div>     
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </div>

                    <div class="list-search-th">
                        传动:    
                    </div>

                    <div class="list-search-block">  
                        <asp:GridView ID="gvwGroupByTransmission" runat="server" AutoGenerateColumns="false" AllowPaging="false" DataKeyNames="GroupId"
                             AllowSorting="false" CssClass="gvwFilterItem" ShowHeader="false" OnRowDataBound="gvwGroupByStatsOnRowDataBound">
                            <Columns>
                                <asp:TemplateField ShowHeader="false" >
                                    <ItemTemplate> 
                                        <div class="search-list-group">
                                            <asp:CheckBox ID="cbxGroupName" runat="server" AutoPostBack="true" OnCheckedChanged="cbxTransmissionType_CheckedChanged" CssClass="cbxGroupName" />
                                            <asp:Label ID="lblCount" runat="server" CssClass="lblCount" />
                                        </div>     
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </div>
            
                    <div class="list-search-th">
                        车况:
                    </div>
            
                    <div class="list-search-block">  
                        <asp:GridView ID="gvwGroupByCondition" runat="server" AutoGenerateColumns="false" AllowPaging="false" DataKeyNames="GroupId"
                             AllowSorting="false" CssClass="gvwFilterItem" OnRowDataBound="gvwGroupByStatsOnRowDataBound" ShowHeader="false">
                            <Columns>
                                <asp:TemplateField ShowHeader="false" >
                                    <ItemTemplate> 
                                        <div class="search-list-group">
                                            <asp:CheckBox ID="cbxGroupName" runat="server" AutoPostBack="true" OnCheckedChanged="cbxCondition_CheckedChanged" CssClass="cbxGroupName" />
                                            <asp:Label ID="lblCount" runat="server" CssClass="lblCount" />
                                        </div>     
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </div>
            
                    <div class="list-search-th">
                        卖家:
                    </div>
            
                    <div class="list-search-block"> 
                        <asp:GridView ID="gvwGroupByListingType" runat="server" AutoGenerateColumns="false" AllowPaging="false" DataKeyNames="GroupId"
                             AllowSorting="false" CssClass="gvwFilterItem" OnRowDataBound="gvwGroupByStatsOnRowDataBound" ShowHeader="false">
                            <Columns>
                                <asp:TemplateField ShowHeader="false" >
                                    <ItemTemplate> 
                                        <div class="search-list-group">
                                            <asp:CheckBox ID="cbxGroupName" runat="server" AutoPostBack="true" OnCheckedChanged="cbxListingType_CheckedChanged" CssClass="cbxGroupName" />
                                            <asp:Label ID="lblCount" runat="server" CssClass="lblCount"/>
                                        </div>     
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </div>            
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>

        <div id="post-list">
            <asp:UpdatePanel ID="udpList" runat="server">
                <ContentTemplate>    
                    <div id="post-list-top">
                        <ul class="horizontal order-by">
                            <li class="order-by-first">排序 
                            </li>
                            <li>
                                <asp:DropDownList ID="ddlOrderBy" runat="server" CssClass="ddlOrderBy selectpicker" />
                            </li>
                            <li class="order-by-btn">
                                <asp:ImageButton ID="btnOrderByAsc" ImageUrl="~/Images/Up_1.png" runat="server" OnClick="OrderByDesc" CssClass="btnOrder" />
                            </li>
                            <li class="order-by-btn">
                                <asp:ImageButton ID="btnOrderByDesc" ImageUrl="~/Images/Down_1.png" runat="server" OnClick="OrderByAsc" CssClass="btnOrder" />
                            </li>
                        </ul>
                        <div id="list-total-num">
                            共<asp:Label ID="lblTotalNumber" ClientIDMode="Static" runat="server" CssClass="lblTotalNumber" />个
                        </div>
                        <div id="top-pager">
                            <webdiyer:AspNetPager ID="TopListPager" runat="server" CssClass="top-pagination" CurrentPageButtonClass="CurrentPage"
                                OnPageChanged="TopListPagerPageChanged" AlwaysShowFirstLastPageNumber="true" NumericButtonCount="3"
                                NumericButtonTextFormatString="{0}" ShowPageIndexBox="Never" />
                        </div>
                        <div class="clear"></div>
                    </div>
                    
                    <div id="gvwAdList-div">
                        <asp:GridView ID="gvwAdList" CssClass="gvwAdList" runat="Server" AutoGenerateColumns="false" DataKeyNames="AdId"
                            AllowPaging="true" OnRowDataBound="gvwAdList_RowDataBound" ShowHeader="false" PagerSettings-Visible="false">
                            <EmptyDataTemplate>
                                <div id="no-result-find"> 
                                    <asp:Localize ID="locNoResultFound" runat="server" meta:resourcekey="NoResultFound" />
                                </div>
                            </EmptyDataTemplate>
                            <Columns>
                                <asp:TemplateField ShowHeader="false">
                                    <ItemTemplate>
                                        <table class="tbl-ad-row">
                                            <tr>
                                                <td rowspan="2" class="td-ad-profile">
                                                    <asp:HyperLink ID="hlkProfilePic" runat="server" CssClass="hlkAdTitle" Target="_blank">
                                                        <asp:Image ID="imgProfile" runat="server" CssClass="imgProfile" />
                                                    </asp:HyperLink>
                                                </td>
                                                <td class="td-ad-detail">
                                                    <div class="vehicle-type">
                                                        <asp:HyperLink ID="hlkAdTitle" runat="server" CssClass="hlkAdTitle" Target="_blank">
                                                            <asp:Label ID="lblVehicleType" runat="server" CssClass="lblVehicleType" />     
                                                        </asp:HyperLink>
                                                        <asp:Image ID="imgSaved" runat="server" ImageUrl="~/Images/tick.png" AlternateText="已收藏" ToolTip="已收藏"  />
                                                        <asp:HyperLink ID="hlkSavePost" runat="server" Text="+收藏" CssClass="hlkSavePost" />
                                                    </div>
                                                    <div>
                                                        <asp:Label ID="lblMileage" runat="server" CssClass="lblMileage" />  
                                                    </div>
                                                    <div class="ad-detail-city">
                                                        <asp:Label ID="lblPrice" runat="server" CssClass="lblPrice" />  

                                                        <asp:Label ID="lblCityLabel" runat="server" Text="城市:" CssClass="lblLabel" /> 
                                                        <asp:Label ID="lblCity" runat="server" CssClass="lblCity" />  
                                                        <div>
                                                            <asp:Label ID="lblPostDateLabel" runat="server" Text="发布:" CssClass="lblPostDateLabel lblLabel" /> 
                                                            <asp:Label ID="lblPostDate" runat="server" CssClass="lblCity" />   
                                                        </div>
                                                    </div>
                                                    <div class="ad-detail-logo">
                                                        <asp:Image ID="imgLogo" runat="server" CssClass="imgLogo" />        
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>

                        <webdiyer:AspNetPager ID="ListPager" runat="server" Width="100%" CssClass="pagination" CurrentPageButtonClass="CurrentPage"
                            OnPageChanged="ListPagerPageChanged" AlwaysShowFirstLastPageNumber="true"
                            NumericButtonTextFormatString="{0}" ShowPageIndexBox="Never" />
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
        
        <div class="clear"></div>
    </div>
</asp:Content>
